﻿#include "TcpServer.h"

bool g_Run = true;
void cmdThread()
{
	while (true)
	{
		char cmdBuf[256] = {};
		scanf("%s", cmdBuf);
		if (0 == strcmp(cmdBuf, "exit"))
		{
			g_Run = false;
			printf("退出cmdThread线程\n");
			break;
		}
		else
		{
			printf("不支持的命令。\n");
		}
	}
}

int main()
{
	TcpServer server;
	server.initSocket();
	server.setServerConfig(nullptr, 4567);
	server.startTaskThread();

	//启动命令线程可退出
	std::thread cmd(cmdThread);
	cmd.detach();

	while (g_Run)
	{
		server.onConnect();
		//printf("空闲时间处理其它业务..\n");
	}

	server.closeServer();
	printf("已退出。\n");

	return 0;
}

